<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        function getRandom(max, min) {
            return Math.floor(Math.random() * (max - min + 1)) + min;
        }
        var random = getRandom(1, 50);
        for (i = 1; i <= 10; i++) {
            var num = prompt('请输入一个数字1~50:');
            if (num < random) {
                alert('你猜小了');
            } else if (num > random) {
                alert('你猜大了');
            } else if (num == random) {
                alert('你猜对了');
                break;
            }
        }
    </script>
</head>

<body>

</body>

</html>